require(['./config'], () => {
    require(['request','header', 'footer', 'jquery'], (req) => {
        class register {
            constructor() {
                this.setData()
            }
            setData() {
                $('.register').click(function () {
                    const name = $('.name').val()
                    const password = $('.password').val()
                    req.register(name, password)
                        .then(res => {
                            console.log(res);
                            // 返回值为成功，代表注册成功
                            if(res === '成功'){
                                alert('注册成功，去登陆')
                                window.location.href = '/html/login.html'
                            }
                            // 返回值为成功，代表注册成功
                            else {
                                alert('注册失败，用户名已存在')
                            }
                        })
                })
            }
        }
        return new register()
    })
})